package jgame;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.JPanel;

import jgame.model.Unit;

public class DrawPanel extends JPanel {

	private GameManager gameManager;

	public void setGameManager(GameManager gameManager) {
		this.gameManager = gameManager;
	}

	public DrawPanel() {
		this.setOpaque(true);
		this.setBackground(Color.white);

		this.gameManager = gameManager;
	}

	protected void paintComponent(Graphics g) {
		super.paintComponent(g);

		try {
			if (this.gameManager.units != null) {
				for (Unit unit : this.gameManager.units) {
					g.drawOval(unit.getPosition().getX(),
							unit.getPosition().getY(), 4, 4);
				}
			}
		}
		catch(Exception e) {
			
		}

	}
}
